﻿using System.CommandLine;
using System.CommandLine.Builder;
using System.CommandLine.Parsing;
using Spectre.Console;

namespace ConsoleToolApp
{
    internal class Program
    {
        static async Task Main(string[] args)
        {



            var yearOption = new Option<bool>("--year")
            {
                Description = "Current Year Progress",
                IsRequired = false,

            };

            yearOption.AddAlias("-y");
            // 默认是年进度
            yearOption.SetDefaultValue(true);

            var monthOption = new Option<bool>("--month")
            {
                Description = "Current Month Progress",
                IsRequired = true
            };
            monthOption.AddAlias("-m");
            monthOption.SetDefaultValue(false);

            var weekOption = new Option<bool>("--week")
            {
                Description = "Current Week Progress",
                IsRequired = true
            };
            weekOption.AddAlias("-w");
            weekOption.SetDefaultValue(false);


            var dayOption = new Option<bool>("--day")
            {
                Description = "Current Day Progress",
                IsRequired = true
            };
            dayOption.AddAlias("-d");
            dayOption.SetDefaultValue(false);



            RootCommand rootCommand = new("ProgressTracker (PT) is a console application designed to track yearly, monthly, and other customizable time-based progress.")
            {
                yearOption,
                monthOption,
                weekOption,
                dayOption
            };


            rootCommand.SetHandler(MainOperations.Run, yearOption, monthOption, weekOption, dayOption);

            var commandLineBuilder = new CommandLineBuilder(rootCommand);

            commandLineBuilder.AddMiddleware(async (context, next) =>
            {
                await next(context);
            });

            commandLineBuilder.UseDefaults();
            Parser parser = commandLineBuilder.Build();

            await parser.InvokeAsync(args);

        }



    }
}
